package cn.attackme.myuploader.result;

/**
 * @Author:arshost
 * @Description:  定义响应状态返回码
 * @Date: Create in 10:39 2019-12-31
 * @Modify:
 */

public enum ResponseStatues {

    EXCEPTION(0,"异常"),
    SUCCESS(200, "成功"),
    SUCCESSLOGIN(200, "登录成功"),
    FAIL(999, "失败"),
    CLEAR(200,"清空成功！"),

    UPLOAD_ERROR(500, "文件解析错误"),
    UPDATE_ERROR(501,"更新数据错误"),
    DEL_ERROR(502, "删除数据错误"),
    DOWNLOAD_ERROR(503, "下载错误"),
    RES_ERROR(504, "恢复数据错误"),

    PARAM_ERROR(1422, "参数错误"),//参数类型转换其他类型过程出现的异常
    PWD_ERROR(1423, "密码错误"),
    LOGIN_ERROR(1424, "登录错误"),
    PARAM_ISEMPTY(1425, "缺少参数"),
    NEWS_NO_EXITS(1426, "新闻不存在"),
    PRODUCT_NO_EXITS(1427, "产品不存在"),
    INFO_NO_EXITS(1428, "公示信息不存在"),
    // 用户相关
    USER_NO_PERMISSION(1001,"没有权限"),
    USER_NO_LOGIN(1002, "用户未登录"),
    USER_ERROR_PASSWORD(1003, "密码错误"),
    USER_NO_EXITS(1004,"用户不存在"),
    USER_EXITS(1005,"用户已存在"),
    // 角色相关
    ROLE_EXITS(1105,"角色已存在"),
    ROLE_NO_EXITS(1104,"角色不存在"),
    ROLE_DEL_ERROR(1103,"系统角色删除失败"),
    ROLE_UPDATE_ERROR(1102,"系统角色更新失败"),
    ROLE_NO_PERMISSION(1101,"角色等级不足"),
    //文件上传
    UPLOAD_EMPTY_ERROR(2001,"空文件上传错误"),
    ;

    private Integer code;
    private String message;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }


    ResponseStatues(int code, String message) {
        this.code = code;
        this.message = message;
    }

    // 根据ID获取MESSAGE
    public static String getMessageByCode(Integer code) {
        for (ResponseStatues ele: values()) {
            if(ele.getCode().equals(code)) {
                return ele.getMessage();
            }
        }
        return null;
    }
}
